<script lang="ts" setup>
import { defineProps, defineEmits } from "vue"
const emits = defineEmits<{
  (e: "currentChange", data: number): void
}>()
const props = defineProps({
  total: {
    type: Number,
    default: 0
  },
  fixed: {
    type: String,
    default: "right"
  },
  // 当前默认页码
  currentPage: {
    type: Number,
    default: 1
  }
})
const currentChangeFun = (page: number) => {
  emits("currentChange", page)
}
</script>

<!-- 分页 -->
<template>
  <div class="pagination">
    <el-pagination
      background
      layout="prev, pager, next"
      :current-page="props.currentPage"
      @current-change="currentChangeFun"
      :total="props.total"
    />
  </div>
</template>

<style lang="scss" scoped>
.pagination {
  margin-top: 8px;
  display: flex;
  justify-content: v-bind("props.fixed");
}
</style>
